/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.unam.ia.grafica;

import org.jfree.chart.*;
import org.jfree.chart.renderer.xy.XYSplineRenderer;
import org.jfree.chart.plot.*;
import org.jfree.data.xy.*;
import org.jfree.ui.RefineryUtilities;

/**
 *
 * @author Jorge A Hernandez
 */
public class Grafica {

    public ChartFrame marco= null;

	public void muestraGraf(double x[],double y[],double x2[],double y2[],int d,String leyenda,String leyenda2)
	{
	XYSeriesCollection datos = creaDatos(x,y,d,leyenda);
        datos.addSeries(creaSerieExtra(x2,y2,d,leyenda2));

        //JFreeChart chart = ChartFactory.createLineXYChart("Algoritmos Genómicos", "x", "y",datos,PlotOrientation.VERTICAL,true,true,true);
         JFreeChart chart = ChartFactory.createScatterPlot("Algoritmos Genéticos", "x", "y",datos,PlotOrientation.VERTICAL,true,true,true);
chart.getXYPlot().setRenderer(new XYSplineRenderer());
                     this.marco = new ChartFrame("Inteligencia Artificial", chart);
            this.marco.pack();
            RefineryUtilities.positionFrameRandomly(this.marco);
            this.marco.setVisible(true);
            }


	public static XYSeriesCollection creaDatos(double x[],double y[],int d,String leyenda)
	{
		XYSeries series = new XYSeries(leyenda);
		for(int k=0;k<d;k++)
		{
		series.add(x[k],y[k]);
		}
		XYSeriesCollection xyDatos = new XYSeriesCollection(series);
		return xyDatos;
	}

        public static XYSeries creaSerieExtra(double x[],double y[],int d,String leyenda)
	{
		XYSeries series = new XYSeries(leyenda);
		for(int k=0;k<d;k++)
		{
		series.add(x[k],y[k]);
		}

		return series;
	}
}
